<?php
if($this->session->userdata('user_id')) {
    $userInfo = getUserInfo($this->session->userdata('user_id'));
}
    
?>
<?php
        if(!$this->session->userdata('user_id')){
?>
        <div class="menu-user  col-sm-12 col-md-3 col-xs-12">
            <ul>
            <li><a href="<?php echo site_url('buyer/signup');?>" title="đăng ký">Đăng kí &nbsp; |</a>
            </li>
            <li><a href="#"title="đăng ký" id="link-log-in">Đăng nhập</a>
            </li>
            </ul>
        </div>
<?php $this->load->view("popup-login");
    $this->load->view('users/modalLoginFacebook');
    $this->load->view('users/modal-register');
    $this->load->view('users/modal-register-google');
    $this->load->view('users/modalLoginGoogle');
    } else {?>
<div class="menu-user dropdown col-sm-12 col-md-4 col-xs-12">
    <a data-toggle="dropdown" class="dropdown-toggle" href="#"><?php echo $userInfo->user_name;?>
    <span class="caret"></span> Điểm
        <?php $score = getUserScore($this->loggedInUser->id);
            if(isset($score->amount) == TRUE)
                echo "<b id='balance-user'>".$score->amount."</b>";
            else echo "<i>0</i>";
        ?> | <?php echo $this->lang->line('Notification')." (<span id='message-user' style='color:red;'>".getTotalMessages()."</span>)";?></a>
    <ul class="dropdown-menu menu-drop" role="menu" aria-labelledby="dLabel">
        <?php if($userInfo->role_id == 1){?>

        <li><a href="<?php echo site_url('buyer/viewMyProjects');?>"><?php echo $this->lang->line('Dashboard');?></a></li>

        <li><a href="<?php echo site_url('buyer/editProfileUpdate');?>"><?php echo $this->lang->line('Profile');?></a>
        </li>
        <li class="notifications">
            <a href="<?php echo site_url('messages/showAllMessage');?>" style="cursor: pointer" data-placement='above' class="danger" data-toogle="popover" title="Popover Title"><?php echo $this->lang->line('Notification')." (".getTotalMessages().")";?></a>
        </li>
        <li style="padding-left:0px !important">
            <a href="<?php echo site_url('users/logout');?>"><?php echo $this->lang->line('Logout');?></a>
        </li>

        <?php }else{?>
        <li><a href="<?php echo site_url('programmer/viewMyProjects');?>"><?php echo $this->lang->line('Dashboard');?></a></li>

        <li><a href="<?php echo site_url('buyer/editProfileUpdate');?>"><?php echo $this->lang->line('Profile');?></a></li>
        <li class="notifications">
                <a href="<?php echo site_url('messages/showAllMessage');?>"style="cursor: pointer" data-placement='above' title="Popover Title"><?php echo $this->lang->line('Notification')." (".getTotalMessages().")";?></a>
        </li>
        <li style="padding-left:0px !important">
            <a href="<?php echo site_url('users/logout');?>"><?php echo $this->lang->line('Logout');?></a>
        </li>
        <?php } ?>
        <?php
        } ?>
    </ul>
</div>

<script type="text/javascript">
    $(document).ready(function(){
        // pop-up login
        $("#link-log-in").click(function(e){
                e.preventDefault();
                $("#login-modal").modal('show');
        })// end tag <a> click
    });
</script>

<?php
    /*if($this->session->userdata('user_id'))
        $this->load->view('users/notifications');*/
?>

